#include <iostream>
#include <pthread.h>
using namespace std;
typedef void (*callback_t)();
static int num = 1;
class Thread
{
public:
    static void *Coutine(void *args)
    {
        Thread *td = static_cast<Thread *>(args);
        td->Entry();
    }
    void Entry()
    {
        cb_();
    }

public:
    Thread(callback_t cb) : tid_(0), name_(""), timestamp_(0), isrunning_(false), cb_(cb)
    {
    }
    void Run()
    {
        name_ = "thread-" + to_string(num++);
        isrunning_ = true;
        timestamp_ = time(nullptr);
        pthread_create(&tid_, nullptr, Coutine, this);
    }
    void Join()
    {
        pthread_join(tid_, nullptr);
        isrunning_ = false;
    }
    bool IsRunning()
    {
        return isrunning_;
    }
    std::string Name()
    {
        return name_;
    }
    uint64_t Timestamp()
    {
        return timestamp_;
    }
    ~Thread() {}

public:
    pthread_t tid_;
    std::string name_;
    uint64_t timestamp_;
    bool isrunning_;
    callback_t cb_;
};